<html>
<head><meta charset="utf-8"><title>align_to · miri · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/index.html">miri</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html">align_to</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="233975549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233975549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233975549">(Apr 10 2021 at 18:18)</a>:</h4>
<p>When did miri start supporting align_to? i seem to remember it used to return everything in the first arm of the tuple, but it seems to properly handle stuff now.</p>
<p>Does it still ever return it all in the first arm, or otherwise "spuriously fail"? say, aligning &amp;[u8] to &amp;[usize].</p>



<a name="233975980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233975980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233975980">(Apr 10 2021 at 18:24)</a>:</h4>
<p>I'm optimizing a function in libcore, and in the past when I've done similar optimizations to this, I've had to cfg(not(miri)) it off, because it needed to align pointers. This time normal align_to works for my needs, but i remember miri being a bit... annoying with it in the past</p>



<a name="233978264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978264">(Apr 10 2021 at 18:55)</a>:</h4>
<blockquote>
<p>When did miri start supporting align_to?</p>
</blockquote>
<p><a href="https://github.com/rust-lang/miri/pull/1513">https://github.com/rust-lang/miri/pull/1513</a></p>



<a name="233978313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978313">(Apr 10 2021 at 18:56)</a>:</h4>
<p>under default flags, Miri should behave exactly like runtime code now. so I guess that is a "no" to your 2nd question.</p>



<a name="233978328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978328">(Apr 10 2021 at 18:56)</a>:</h4>
<p><code>-Zmiri-symbolic-alignment-check</code> opts-in to the old behavior</p>



<a name="233978385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978385">(Apr 10 2021 at 18:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/269128-miri/topic/align_to/near/233975980">said</a>:</p>
<blockquote>
<p>I'm optimizing a function in libcore, and in the past when I've done similar optimizations to this, I've had to cfg(not(miri)) it off, because it needed to align pointers. This time normal align_to works for my needs, but i remember miri being a bit... annoying with it in the past</p>
</blockquote>
<p>this is surprising; don't these optimizations have to handle the unaligned lead/tail anyway? so they should work under symbolic alignment without extra work, since that will just mean that the lead/tail loop ends up doing <em>all</em> the work?</p>



<a name="233978804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978804">(Apr 10 2021 at 19:03)</a>:</h4>
<blockquote>
<p>don't these optimizations have to handle the unaligned lead/tail anyway</p>
</blockquote>
<p>They do, but LLVM has some issues determining the size of the slice and ends up unrolling and autovectorizing a lot on a function never called with a slice larger than size_of::&lt;usize&gt;(). might have found another workaround, though</p>



<a name="233978865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978865">(Apr 10 2021 at 19:04)</a>:</h4>
<p>the llvm behavior is not a dealbreaker but the reason i noticed this function was llvm doing a bad job on autovec</p>



<a name="233978949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978949">(Apr 10 2021 at 19:05)</a>:</h4>
<p>oh I see</p>



<a name="233978959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233978959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233978959">(Apr 10 2021 at 19:05)</a>:</h4>
<p>well I assume symbolic alignment support will inevitably bitrot over time, I kind of gave up on that fight^^</p>



<a name="233979019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233979019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233979019">(Apr 10 2021 at 19:06)</a>:</h4>
<p>so if it's a lot of work... don't feel obliged to support that</p>



<a name="233979624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233979624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233979624">(Apr 10 2021 at 19:15)</a>:</h4>
<p>so, while i'm pretty sure this workaround solves the issue, and actually improves performance further</p>



<a name="233979655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233979655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233979655">(Apr 10 2021 at 19:15)</a>:</h4>
<p>i'm actually glad to hear about that since it made it hard to test alignement-sensitive code over all possible alignments in miri</p>



<a name="233979670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/269128-miri/topic/align_to/near/233979670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/269128-miri/topic/align_to.html#233979670">(Apr 10 2021 at 19:15)</a>:</h4>
<p>it felt like the kind of thing that was more useful if you didnt test your code (enough) &gt;_&gt;</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>